%set(gcf, 'Renderer', 'painters');
%set(gca,'nextplot','replacechildren');
%set(gca,'replace');
%set(gcf,'Renderer','zbuffer');
close all;
clear all;

cdcfr = VideoWriter('RecA_2hr_3k2a_unifRec.avi','Uncompressed AVI');
cdcfr.FrameRate = 10;
open(cdcfr);

dt=20./60.; %time between each snapshot. Taken from RUN_GDI_SK_20June2011.m
cdc42=importdata('data_Cdc42T_time_course',' ');
rat=importdata('data_reca_time_course',' ');
N=size(cdc42,2);
fig2=figure(2);
fig3=figure(3);
hold off;
if mod(size(cdc42,1),size(cdc42,2))~=0
    display('Some frames were not fully written! The further progression of the script will be erroneous\n');
else
    Nf=size(cdc42,1)/size(cdc42,2);
    %clf reset;
    for i=0:(Nf-1)
        c=cdc42(1+i*N:N+i*N,:);
        r=rat(1+i*N:N+i*N,:);
        fig2;
        clim=[0 4];
        imagesc(r,clim)
        colorbar;
        title(['RecA bound to GEF. Time = ' num2str(round(i*dt)) ' min.'],'fontsize',20);
        fr=getframe(fig2);
        writeVideo(cdcfr,fr);
%         fig3;
%         clim=[0 max(max(c))];
%         imagesc(c,clim);
%         colorbar;
%         title(['Total Cdc42 bound to GTP. Time = ' num2str(round(i*dt)) ' min.'],'fontsize',20);
%         fr=getframe(fig2);
%         writeVideo(cdcfr,fr);
    end
end
% 
 close(cdcfr);
